import openpyxl
import requests

headers = {
    "Accept": "application/json, text/plain, */*",
    "Accept-Encoding": "gzip, deflate",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-US;q=0.7",
    "Connection": "keep-alive",
    "Content-Length": "831",
    "Cookie": "esso-authId=esso-1qoietiu3iq1a804165b4cf4271a2eb98df6e05ffdf; "
              "authId=sso-1em4lfnqncp1695a9a4830b4f0685f2950e76b09b98; route=44ddb86281fc94ce2bb85de6b7604318",
    "Host": "elk.weidai.com.cn",
    "Origin": "http://elk.weidai.com.cn",
    "Referer": "http://elk.weidai.com.cn/app/kibana",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 "
                  "Safari/537.36 Edg/113.0.0.0",
    "content-type": "application/x-ndjson",
    "kbn-version": "6.8.0"
}


def ruin():
    workbook = openpyxl.load_workbook('C:/Users/九分石人/Documents/华翔语音坐席.xlsx')
    sheets = workbook.worksheets[0]
    rows = sheets.rows
    return rows


if __name__ == '__main__':
    payload = "{\"index\":\"scat*\",\"ignore_unavailable\":true,\"preference\":1680053902257}{\"version\":true," \
              "\"size\":500,\"sort\":[{\"@timestamp\":{\"order\":\"desc\",\"unmapped_type\":\"boolean\"}}]," \
              "\"_source\":{\"excludes\":[]},\"aggs\":{\"2\":{\"date_histogram\":{\"field\":\"@timestamp\"," \
              "\"interval\":\"30m\",\"time_zone\":\"Asia/Shanghai\",\"min_doc_count\":1}}},\"stored_fields\":[\"*\"]," \
              "\"script_fields\":{},\"docvalue_fields\":[{\"field\":\"@timestamp\",\"format\":\"date_time\"}]," \
              "\"query\":{\"bool\":{\"must\":[{\"query_string\":{\"query\":\"\"596423a34e14f41c\"\"," \
              "\"analyze_wildcard\":true,\"default_field\":\"*\"}},{\"range\":{\"@timestamp\":{\"gte\":1680019200000," \
              "\"lte\":1680105599999,\"format\":\"epoch_millis\"}}}],\"filter\":[],\"should\":[],\"must_not\":[]}}," \
              "\"highlight\":{\"pre_tags\":[\"@kibana-highlighted-field@\"],\"post_tags\":[" \
              "\"@/kibana-highlighted-field@\"],\"fields\":{\"*\":{}},\"fragment_size\":2147483647}," \
              "\"timeout\":\"30000ms\""
    print(payload)
    post = requests.post(
        url='http://elk.weidai.com.cn/elasticsearch/_msearch?rest_total_hits_as_int=true&ignore_throttled=true',
        data=payload,
        headers=headers)
    print(post.content.decode('utf-8'))
